package com.algoruthm6;

import java.util.Arrays;

public class SelectionSort {
    public static void sort(int[] array){
        for(int i=0;i<array.length-1;i++) {
            int min = i;
            for(int j=i;j<array.length;j++){
                if(array[j]<array[min]){
                    min = j;
                }
            }
            if(min==i){
                return;
            }
            Utils.swap(array,min,i);
            System.out.println("i="+i+"-->"+ Arrays.toString(array));
        }
    }
    public static void main(String[] args){
        int[] array = new int[]{4,3,6,8,9,7,10,5,1,2};
        System.out.println("array:"+ Arrays.toString(array));
        sort(array);
        System.out.println("sorted array:"+ Arrays.toString(array));
    }
}
